package com.kommii.test;

import java.util.List;

import com.hddf.project.auth.pojos.Authority;
import com.hddf.project.auth.service.AuthService;
import com.hddf.project.auth.service.MongoDB_Query;
import com.mongodb.DBObject;

public class authmongodb_test {

	public static void getAuthList(String start,String limit,int state){
		MongoDB_Query mq = MongoDB_Query.getInstance();
		List<DBObject> list = mq.getAuthList(start, limit, state);
		int s = list.size();
		DBObject obj = null;
		System.out.println(s);
		for(int i=0;i<s;i++){
			obj = list.get(i);
			System.out.println(obj.get("url"));
			System.out.println(obj.get("name"));
		}
	}
	
	public static void getAuthTotalCount(int state){
		MongoDB_Query mq = MongoDB_Query.getInstance();
		int s = mq.getAuthTotalCount( state);
		System.out.println(s);
		
	}
	
	public static void getByName(String name){
		AuthService as = AuthService.getInstance();
		Authority auth = as.getAuthByName(name);
		System.out.println(auth.getName());
		System.out.println(auth.getUrl());
	}
	
	public static void getAuthByUser(){
		MongoDB_Query mq = MongoDB_Query.getInstance();
		String ids = "1,7";
		List<DBObject> list = mq.getAuthByUser(ids);
		int s = list.size();
		DBObject auth = null;
		for(int i=0;i<s ; i++){
			auth = list.get(i);
			System.out.println(auth.get("name"));
		}
	}
	
	public static void main(String[] args) {
		getAuthTotalCount(-1);
		//getAuthByUser();
		//getAuthList();
		//getById(1);
		//getByName("用户管理");
		//getAuthList("12","5",1);
	}

}
